package com.fafa.swing.base;

import javax.swing.*;
import java.awt.*;

/**
 * @author : fafa
 * @version V1.0
 * @Project: SwingTest
 * @Package com.fafa.swing
 * @Description: JButtonDemo
 * @date Date : 2019年11月23日 14:55
 */
public class JButtonDemo extends JFrame {
    public static void main(String[] args) {

        JFrame jFrame = new JFrame("按钮示例组件");
        jFrame.setSize(400,200);
        JPanel jPanel = new JPanel();
        JButton jButton1 = new JButton("我是普通按钮");
        JButton jButton2 = new JButton("我是带背景的按钮");
        JButton jButton3 = new JButton("我是不可用按钮");
        JButton jButton4 = new JButton("我是底部对齐按钮");
        jPanel.add(jButton1);
        jButton2.setBackground(Color.YELLOW);
        jPanel.add(jButton2);
        jButton3.setEnabled(false);
        jPanel.add(jButton3);
        Dimension dimension = new Dimension(160,60);
        jButton4.setPreferredSize(dimension);
        jButton4.setVerticalAlignment(SwingConstants.BOTTOM);
        jPanel.add(jButton4);

        jFrame.add(jPanel);
        jFrame.setBounds(300,200,600,300);
        jFrame.setVisible(true);
        jFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    }
}
